﻿using System;
using System.Collections.Generic;
using Cesave.Domain.PermisosModule.Contracts.Acls;
using Cesave.Domain.PermisosModule.Entities;
using Cesave.Infrastructure.CrossCutting.Logging;
using Cesave.Infrastructure.Data.Core;
using Cesave.Infrastructure.Data.PermisosModule.Context;

namespace Cesave.Infrastructure.Data.PermisosModule.Repositories
{
	/// <summary>
	/// 
	/// </summary>
	public class AclRepository
		: GenericRepositoryEx<Acl>, IAclRepository
	{
		#region Constructor

		/// <summary>
		/// 
		/// </summary>
		/// <param name="context"></param>
		/// <param name="traceManager"></param>
		public AclRepository(IPermisosModuleContext context, ITraceManager traceManager)
			: base(context, traceManager)
		{
		}

		#endregion

		#region IAclRepository Members

		/// <summary>
		/// 
		/// </summary>
		/// <param name="aclByGuidSpecification"></param>
		/// <returns></returns>
		public IEnumerable<Acl> FindAclByGuidSpecification(AclByGuidSpecification aclByGuidSpecification)
		{
			if (aclByGuidSpecification == null)
				throw new ArgumentNullException("aclByGuidSpecification");
			return GetFilteredElements(aclByGuidSpecification.SatisfiedBy(), acl => acl.AclId, true);
		}

		#endregion
	}
}
